<template>
  <div class="technicDetail">
    <van-nav-bar>
      <template #left>
        <i @click="$router.back()" class="iconfont icon-zuojiantou"></i>
      </template>
    </van-nav-bar>
    <div class="item">
      <div class="title">{{ detail.title }}</div>
      <div class="content">
        <div class="date">{{ date }}</div>
        <div class="see">
          <van-icon name="eye-o" />
          {{ detail.read }}
        </div>
        <div class="good">
          <good-job
            :id="detail.id"
            :class="`${list.includes(detail.id) ? 'active' : ''}`"
          />
          {{ detail.star }}
        </div>
      </div>
      <div v-html="detail.content"></div>
    </div>
  </div>
</template>

<script>
import GoodJob from '@/components/Find/GoodJob.vue'
import dayjs from 'dayjs'
import { skiisDetail } from '@/api/InterviewSkills'
export default {
  components: { GoodJob },
  methods: {
    getDate () {
      const res = Date.parse(this.detail.created_at)
      const date = dayjs(res).format('YYYY-MM-DD')
      this.date = date
      if (localStorage.getItem('goodList')) {
        this.list = JSON.parse(localStorage.getItem('goodList'))
      }
    }
  },
  data () {
    return {
      detail: {},
      date: '',
      list: []
    }
  },
  async created () {
    const res = await skiisDetail(this.$route.params.id)
    console.log(res);
    this.detail = res.data
    this.getDate()
  },
}
</script>

<style lang="less" scoped>
.technicDetail {
  .iconfont {
    font-size: 1.875rem;
  }
  .item {
    padding: 0.9375rem;
    .title {
      color: #181a39;
      font-weight: 500;
    }
    .content {
      font-size: 0.75rem;
      margin-top: 0.625rem;
      color: #b4b4bd;
      display: flex;
      .date {
        flex: 1;
      }
      .good {
        margin-left: 0.9375rem;
        .active {
          color: #e40137 !important;
        }
      }
    }
  }
}
</style>
